import pymysql

connection = pymysql.connect(
    host='localhost',  # 仓库地址
    user='root',       # 仓库管理员
    password='1234',   # 管理员密码
    database='hqyj',   # 指定仓库
    port=3306,         # 仓库门牌号
    charset='utf8'     # 沟通语言
)

cursor = connection.cursor()

cursor.execute(
"""
CREATE TABLE IF NOT EXISTS tb_users (
    id INT PRIMARY KEY AUTO_INCREMENT,
    username VARCHAR(20) NOT NULL UNIQUE,
    password VARCHAR(20) NOT NULL
);
"""
)

# 提交
connection.commit()
print("创建淘宝用户表成功")

# 关闭数据库
cursor.close()
connection.close()